#include "Menu_table.h"


Menu_table::Menu_table(Table* tp) : t(tp)
{

}


Menu_table::~Menu_table(void)
{

}

void Menu_table::start()
{
	int chosen = 0;

	do
	{
		switch(chosen)
		{
		case 1:
			{
				table_col_list();
				break;
			}
		case 2:
			{
				table_add_col();
				break;
			}
		case 3:
			{
				table_del_col();
				break;
			}
		case 4:
			{
				table_select();
				break;
			}
		case 5:
			{
				table_select_cond();
				break;
			}
		case 6:
			{
				table_insert();
				break;
			}
		case 7:
			{
				table_delete();
				break;
			}
		case 8:
			{
				table_truncate();
				break;
			}
		}

		cout << endl << "### Table: " << t->get_name() << " ###" << endl;
		cout << "1. List columns" << endl;
		cout << "2. Add column" << endl;
		cout << "3. Delete column" << endl;
		cout << "4. SELECT from table" << endl;
		cout << "5. Conditional SELECT from table" << endl;
		cout << "6. INSERT into table" << endl;
		cout << "7. Conditional DELETE from table" << endl;
		cout << "8. TRUNCATE table" << endl;
		cout << "9. Back" << endl;
		chosen = Validator::get<int>("Please choose a number: ");
		system("cls");
	} while(chosen != 9);
}

void Menu_table::table_col_list() const
{
	t->col_list();
}

void Menu_table::table_add_col() const
{
	t->col_add();
}

void Menu_table::table_del_col() const
{
	t->col_del();
}

void Menu_table::table_insert() const
{
	t->insert();
}

void Menu_table::table_select() const
{
	t->select(false);
}

void Menu_table::table_select_cond() const
{
	t->select(true);
}

void Menu_table::table_delete() const
{
	t->del(true);
}

void Menu_table::table_truncate() const
{
	t->del(false);
}

